var express = require('express');
// var session = require('express-session');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');

var usersRouter = require('./routes/users');
var logsRouter =require("./routes/loginLog")
var devRouter =require("./routes/dev")
var adminOpaRouter =require("./routes/admin_opa_logs")
var shareRouter =require("./routes/share")
//事务处理
var solveRouter=require("./routes/solve")
//阿里云数据库
var aliyunRouter=require("./util/mySQL")

var filter = require("./middleware/filter")
var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

//session
// app.use(session({
//   secret: 'BI_YE_SHE_JI', //加密的字符串，里面内容可以随便写
//   resave: false,//强制保存session,即使它没变化
//   saveUninitialized: true, //强制将未初始化的session存储，默认为true
//   cookie: { maxAge: 60000 * 60 * 24 * 24 }//过期时间
// }));

app.use(filter)//jwttoken验证
app.use('/users', usersRouter);//管理员基本信息(登录、注册、修改个人基本信息、修改密码、查找管理员列表)
app.use('/getlogs', logsRouter);//登录日志
app.use('/dev', devRouter);//设备基本信息
app.use('/adminlogs', adminOpaRouter);//管理员操作日志
app.use('/share', shareRouter);//信息共享平台

app.use('/solve', solveRouter);//事务处理

app.use('/aliyun', aliyunRouter);//阿里云

module.exports = app;
